package de.cms.kff.ctrl;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.context.SecurityContextHolder;

@Controller
public class HomeController {
	private static Logger log = Logger.getLogger(HomeController.class);

	/**
	 * Custom handler for the welcome view. Note that this handler relies on the
	 * RequestToViewNameTranslator to determine the logical view name based on
	 * the request URL: "/index.html"
	 * 
	 * @return View name "home" selecting view "/view/home.jsp"
	 */
	@RequestMapping("/index.html")
	public ModelAndView edit() {
		log.info("welcome");
		ModelAndView mv = new ModelAndView();
		Authentication auth = SecurityContextHolder.getContext().getAuthentication();
		mv.addObject("title", "Willkommen im System!");
		mv.addObject(
				"message",
				"In diesem System können Sie Ihren Fuhrpark verwalten. Bitte wählen Sie hierfür zunächst Ihre Funktion aus:");
		mv.setViewName("home");
		return mv;
	}

}
